<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>ajax登录页面</title>
    <script src="/static/js/jquery.min.js"></script>
    <script>
        $(function () {
            $('#btnLOGIN').click(function () {
                // 获取用户密码
                // 发起ajax请求
                username = $('#username').val()
                password = $('#password').val()
                $.ajax({
                        'url':'/login_ajax_check',
                        'type':'post',
                        'dataType':'json',
                        'data':{'username':username,'password':password}
                }).success(function (data) {
                    if (data.res==0){
                        $('#errmsg').show().html('用户名密码不正确')
                    }
                    else {
                        location.href = '/index'
                    }
                })
            })
        })
    </script>
      <style>
        #errmsg{
            display: none;
            color: red;
        }
        </style>

</head>
<body>
用户名:<input type="text" id="username"><br/>
密码:<input type="password" id="password"><br/>
<input type="submit" id="btnLOGIN" value="登录">
</form>
<div id="errmsg"></div>
</body>
</html>